package aex.service;



import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import aex.dao.ScoreDao;
import aex.domain.Puser;
import aex.domain.Score;
import aex.util.PageBean;



@Transactional(readOnly = false)
@Service(ScoreService.SERVICE_NAME)

public class ScoreService  {

	
	public static final String SERVICE_NAME="aex.service.ScoreService";
	/**
	 * 以注解的形式让spring为我们注入dao的实现类
	 */
	@Resource(name = ScoreDao.SERVICE_NAME)
	public ScoreDao dao;
	
	public ScoreService() {
	}

	
	public Score findByID(Serializable id) {
		return dao.findObjectByID(Integer.parseInt(id+""));
	}
	public void deleteById(Serializable id) {
		dao.deleteObjectByIDs(Integer.parseInt(id+""));
	}
	public void save(Score obj) {
		dao.save(obj);
	}
	public void update(Score obj) {
		dao.merge(obj);
	}

	public Score getScoreByName(String operationName){
		List<Score> list=dao.findCollectionByConditionNoPage(" and tName.scName='"+operationName+"'", null, null);
		return list.get(0);
	}

	public PageBean<Score> findAll(PageBean<Score> pageBean) {
		LinkedHashMap<String, String> orderby=new LinkedHashMap<String, String>();
		orderby.put("tName.scName", "asc");
		return dao.findPageBean(" " , null, orderby, pageBean);
	}

	
	
}
